<?php
chdir('../../');
require('includes/application_top.php');
require_once(DIR_FS_INC.'inc.calculate_tax.php');
require_once(DIR_FS_INC.'inc.address_label.php');

if (!isset($_SESSION['customers_status']) || $_SESSION['customers_status']['customers_status_id'] != 0)
	die('access denied');

// backsave	
$bs = array();
$bs_keys = array(
	'customers_status',	
	'customer_gender', 'customer_first_name',	'customer_last_name',	
	'customer_id', 'customer_cid','customer_vat_id',	
	'customer_default_address_id',	
	'customer_country_id', 'customer_zone_id'
);
foreach($bs_keys as $val) $bs[$val] = $_SESSION[$val];

if (!isset($_REQUEST['oID']))
	$oID = 155;
else
	$oID = (int)$_REQUEST['oID'];

if (!isset($_REQUEST['type']))
	$type = 'html';
else
	$type = $_REQUEST['type'];
	
$order_check = $db->db_query("SELECT customers_id FROM ".TABLE_ORDERS." WHERE orders_id='".$oID."'");
$_SESSION['customer_id'] = $order_check->fields['customers_id'];

// create vars for send_order
$smarty = new Smarty();
$insert_id = $oID;
define('VIEWMAIL', $type);

include(DIR_FS_CATALOG.'send_order.php');

foreach($bs_keys as $val) $_SESSION[$val] = $bs[$val];
?>